package br.ufc.ck0017.ir.tree;

import java.util.ArrayList;
import java.util.List;

public class CALL implements IRNode {
    private final IRNode function;
    private final List<IRNode> arguments;

    CALL(IRNode function, List<IRNode> arguments) {
        this.function = function;
        this.arguments = new ArrayList<>(arguments);
    }

    @Override
    public List<IRNode> getChildren() {
        List<IRNode> children = new ArrayList<>();
        children.add(function);
        children.addAll(arguments);

        return children;
    }

    @Override
    public IRNode build(List<IRNode> children) {
        return new CALL(children.get(0), children.subList(1, children.size() - 1));
    }
}
